139

The Genius of Collaboration

139

You need two things here—​identification that someone walked in—​which is done

by the first objective of motion detection. And then invoking the text-​to-​speech func­

tion. This simple code is provided below. It does need your laptop speaker so be sure to

turn up your sound. We use a spreadsheet called “Greetings” with the following values:

FIGURE 10.3  Text to speech.

STEP 1

Motion Detection.

Sub Greetings()

Dim FileItem As Object

Dim SourceFolder As Object

x =​ Format(Time, “HH”)

Folder =​ “C:�sers\deepa\Documents\webcam photo\Motion\temp” ‘ this is the

folder that has the motion detection pictures

Set fs =​ CreateObject(“Scripting.FileSystemObject”)

Set SourceFolder =​ fs.GetFolder(Folder)

MotionSensed =​ “N”

For Each FileItem In SourceFolder.Files

xdate =​ Format(Date, “MM/​DD/​YYYY”)

ydate =​ Format(FileDateTime(Folder & “\” & FileItem.Name), “MM/​DD/​YYYY”)

xhh =​ Format(Time, “HH”)

xmm =​ Format(Time, “MM”)

xtime =​ xhh * 60 +​ xmm

Name =​ FileItem.Name

yhh =​ Format(FileDateTime(Folder & “\” & FileItem.Name), “HH”)

ymm =​ Format(FileDateTime(Folder & “\” & FileItem.Name), “NN”)

ytime =​ yhh * 60 +​ ymm

If xdate =​ ydate Then

    If xtime <=​ ytime +​ 1 Then

      MotionSensed =​ “Y”

    Else

End If

Else

    FileItem.Delete

End If

Next